<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>广告API设置</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">

        <div class="layui-card-header">设置创量Api接口调用凭证信息</div>

        <div class="layui-card-body" style="width: 880px;">

            <div class="layui-form" lay-filter="">

                <div class="layui-form-item">
                    <label class="layui-form-label">应用密钥：</label>
                    <div class="layui-input-block">
                        <input type="text" name="secret" value="{$info['secret'] ? $info['secret'] : ''}" lay-verify="secret" lay-verType="tips" placeholder="请输入应用密钥" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">接口域名：</label>
                    <div class="layui-input-block">
                        <input type="text" name="interface_domain" value="{$info['interface_domain'] ? $info['interface_domain'] : ''}" lay-verify="interface_domain" lay-verType="tips" placeholder="请输入接口域名" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">账号邮箱：</label>
                    <div class="layui-input-block">
                        <input type="text" name="email" value="{$info['email'] ? $info['email'] : ''}" placeholder="请输入创量管理员账号邮箱" lay-verify="email" lay-verType="tips" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-normal" lay-submit lay-filter="setting_site">立即提交</button>
                    </div>
                </div>
            </div>

        </div>

    </div>
</div>

<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function(){
        var $ = layui.$
            ,form = layui.form;

        form.verify({

            secret: function(value){
                if(value.length < 1){
                    return '应用密钥不能为空';
                }
            }

            ,interface_domain: function(value){
                if(value.length < 1){
                    return '接口域名不能为空';
                }
            }

            ,email: function(value){
                if(value.length < 1){
                    return '创量管理员账号邮箱不能为空';
                }
            }


        });

        form.on('submit(setting_site)', function(data){

            $.ajax({
                url:"{:url('AdvertUser/api_setting')}",
                type:"post",
                dataType: "json",
                data:data.field,
                async:true,
                success: function(rs){
                    if(rs['code'] == 100){

                        layer.msg(rs['msg'],function () {
                            layer.close(); //关闭弹层
                            window.location.reload();
                        });

                    }else{
                        layer.msg(rs['msg']);
                    }
                    return false;
                }
            });
        });

    })
</script>
</body>
</html>